//登录成功以及出现退出登录
var name=document.getElementsByClassName('userName')[0];
var login=document.getElementsByClassName('login')[0];
var persons=document.getElementsByClassName('persons')[0];
var out=document.getElementsByClassName('out')[0];
var hideLogOut = document.getElementsByClassName('hideLogOut')[0];
var hideLogOutContent = document.getElementsByClassName('hideLogOutContent')[0];
var logOutNoBtn=document.getElementsByClassName('logOutNoBtn')[0];
var logOutYesBtn=document.getElementsByClassName('logOutYesBtn')[0];
if(localStorage.getItem('userHao')!=null || localStorage.getItem('sign')==1){
    login.style.display='none';
    persons.style.display='block';
}
console.log(localStorage.getItem('userHao'))
console.log(localStorage.getItem('password'))
out.onclick=function(){
    setTimeout(function(){
        hideLogOut.style.display = 'block';
        hideLogOutContent.style.opacity = '1';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + 400 + "px)";
    },1)
    logOutNoBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
    }
//点击确认会退出登录
    logOutYesBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
        persons.style.display='none';
        login.style.display='block';
        localStorage.removeItem('userHao');
        localStorage.removeItem('password');
        localStorage.removeItem('sign');
        window.location.href="http://localhost:8080/future/out";
    }


}


// 列表的颜色变化
var inquireTbody = document.getElementsByClassName('inquireTbody')[0];
console.log(inquireTbody.children[0]);
for(var i = 0;i < inquireTbody.children.length;i++){
    if(i%2==0){
        inquireTbody.children[i].style.backgroundColor="white";
    }else{
        inquireTbody.children[i].style.backgroundColor="rgba(0,0,0,.02)";
    }
}


//分页查询
var hideLoad=document.getElementsByClassName('hideLoad')[0];
var hideLoadForm=document.getElementsByClassName('hideLoadForm')[0];
var hideLast=document.getElementsByClassName('hideLast')[0];
var hideLastForm=document.getElementsByClassName('hideLastForm')[0];

var prePage=document.getElementsByClassName('prePage')[0];
var nextPage=document.getElementsByClassName('nextPage')[0];
var page=1;
var toPage=document.getElementsByClassName('toPage')[0];
var allPage=document.getElementsByClassName('allPage')[0].innerHTML
var toFirst=document.getElementsByClassName('toFirst')[0];
var toLast=document.getElementsByClassName('toLast')[0];

toFirst.onclick=function () {
    if(toPage.value<=1){
        hideLoad.style.display = 'block';
        hideLoadForm.style.opacity = '1';
        hideLoadForm.style.transform = "translate(" + -50 + "%)";
        setTimeout(function(){
            hideLoad.style.display = 'none';
            hideLoadForm.style.opacity = '0';
            hideLoadForm.style.transform = "translate(" + -50 + "%)";
        },1000)
    }else{
        location.href = 'http://localhost:8080/future/music/allMusic?page=1';
    }

}
console.log(toPage.value)
console.log(allPage)
toLast.onclick=function (){
    if(toPage.value>=allPage){
        hideLast.style.display = 'block';
        hideLastForm.style.opacity = '1';
        hideLastForm.style.transform = "translate(" + -50 + "%)";
        setTimeout(function(){
            hideLast.style.display = 'none';
            hideLastForm.style.opacity = '0';
            hideLastForm.style.transform = "translate(" + -50 + "%)";
        },1000)
    }else{
        location.href = 'http://localhost:8080/future/music/allMusic?page='+allPage;
    }

}
prePage.onclick=function(){
    if(toPage.value<=1){
        hideLast.style.display = 'block';
        hideLastForm.style.opacity = '1';
        hideLastForm.style.transform = "translate(" + -50 + "%)";
        setTimeout(function(){
            hideLast.style.display = 'none';
            hideLastForm.style.opacity = '0';
            hideLastForm.style.transform = "translate(" + -50 + "%)";
        },1000)
        return;
    }else{
        page=toPage.value-1;
        location.href = 'http://localhost:8080/future/music/allMusic?page='+page;
    }

}
nextPage.onclick=function(){
    console.log(allPage);
    var pagenum = allPage;
    if(Number(toPage.value)>=pagenum){
        hideLast.style.display = 'block';
        hideLastForm.style.opacity = '1';
        hideLastForm.style.transform = "translate(" + -50 + "%)";
        setTimeout(function(){
            hideLast.style.display = 'none';
            hideLastForm.style.opacity = '0';
            hideLastForm.style.transform = "translate(" + -50 + "%)";
        },1000)
        return;
    }else{
        page=Number(toPage.value)+1;
        location.href = 'http://localhost:8080/future/music/allMusic?page='+page;
        console.log(page);
    }
}

//更改页码框中的值
toPage.onkeydown=function(event) {
    var event = event;
    // console.log(event.keyCode)
    if (event.keyCode == 13) {
        location.href = 'http://localhost:8080/future/music/allMusic?page=' + Number(toPage.value);
    }
}
// 判断是否登录
var hideVipLoad=document.getElementsByClassName('hideVipLoad')[0];
var hideVipLoadForm=document.getElementsByClassName('hideVipLoadForm')[0];
var vipBtn=document.getElementsByClassName('vipBtn')[0];
var loadBtn=document.getElementsByClassName('loadBtn')[0];
var closeVip=document.getElementsByClassName('closeVip')[0];
var myMusic=document.getElementsByClassName('myMusic')[0];
// vip的界面
vipBtn.onclick=function(){
    if(localStorage.getItem('userHao')!=null || localStorage.getItem('sign')==1){
        window.location.href='http://localhost:8080/future/toVIPpaper';
    }else{
        hideVipLoad.style.display='block';
        hideVipLoadForm.style.opacity='1';
        closeVip.onclick=function(){
            hideVipLoad.style.display='none';
            hideVipLoadForm.style.opacity='0';
        }
        loadBtn.onclick=function(){
            window.location.href='http://localhost:8080/future/loginpage';
        }
    }

}
// 我的音乐的界面
myMusic.onclick=function(){
    if(localStorage.getItem('userHao')!=null|| localStorage.getItem('sign')==1){
        window.location.href='http://localhost:8080/future/toMyMusicpaper';
    }else{
        hideVipLoad.style.display='block';
        hideVipLoadForm.style.opacity='1';
        closeVip.onclick=function(){
            hideVipLoad.style.display='none';
            hideVipLoadForm.style.opacity='0';
        }
        loadBtn.onclick=function(){
            window.location.href='http://localhost:8080/future/loginpage';
        }
    }
}

// // 判断是否登录 end
